﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MMMaze
{
    public enum Axises3D
    {
        X = 0,
        Y = 1,
        Z = 2
    }

    public class Area3D<TWallContent> : IAreaRoot
    {
        #region IAreaRoot Members
        public Area3D()
        {

            IAxis<IAreaRoot>[] ary = 
                       {
                            new  LinkAxis<IAreaRoot> (){},
                            new  LinkAxis<IAreaRoot> (){},
                            new  LinkAxis<IAreaRoot> (){}
                       };

            
            Axises = ary.ToList();
            Axises.ForEach((o) => Contents.Add((LinkAxis<IAreaRoot>)o, new TWallContent[3]));

        }
        public List<IAxis<IAreaRoot>> Axises
        {
            get;
            set;
        }


        #endregion

        public IAxis<IAreaRoot> AxisX
        {


            get { return GetAxises(Axises3D.X); }
        }


        public IAxis<IAreaRoot> AxisY
        {


            get { return GetAxises(Axises3D.Y); }
        }
        public IAxis<IAreaRoot> AxisZ
        {


            get { return GetAxises(Axises3D.Z); }
        }


        public  IAxis<IAreaRoot> GetAxises(Axises3D axis)
        {
            return Axises[(int)axis];
        }


       private Dictionary<LinkAxis<IAreaRoot>, TWallContent[]> Contents = new Dictionary<LinkAxis<IAreaRoot>, TWallContent[]>(3);
       public TWallContent GetWallContent (Axises3D Axis ,AxisDirection direction ) 
       {
           return Contents[(LinkAxis<IAreaRoot>)Axises[(int)Axis]][(int)direction + 1];
       }


       public void  SetWallContent(Axises3D Axis, AxisDirection direction,TWallContent value  )
       {
           Contents[(LinkAxis<IAreaRoot>)Axises[(int)Axis]][(int)direction + 1] = value;
       }



       public Area3D<TWallContent> XNext
       {
           get { return (Area3D<TWallContent>)AxisX.Next; }
       }
       public Area3D<TWallContent> XPrevious
       {
           get { return (Area3D<TWallContent>)AxisX.Previous; }
       }




       public Area3D<TWallContent> YNext
       {
           get { return (Area3D<TWallContent>)AxisY.Next; }
       }
       public Area3D<TWallContent> YPrevious
       {
           get { return (Area3D<TWallContent>)AxisY.Previous; }
       }

       public Area3D<TWallContent> ZNext
       {
           get { return (Area3D<TWallContent>)AxisZ.Next; }
       }
       public Area3D<TWallContent> ZPrevious
       {
           get { return (Area3D<TWallContent>)AxisZ.Previous; }
       }

    }
}
